
import 'package:demo/empUtils/EMPColorUtils.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

class EMPTheme {

  //判断是否暗黑模式
  static bool isDark(BuildContext context){
    return Theme.of(context).brightness == Brightness.dark;
  }

  static Color? getDarkColor(BuildContext context,Color darkColor){
    return isDark(context) ? darkColor : null;
  }

  static Color? getIconColor(BuildContext context){
    return isDark(context) ? EMPColor.dark_text : null;
  }



  static const SystemUiOverlayStyle light = SystemUiOverlayStyle(
    statusBarColor: Colors.transparent,//状态栏的背景颜色设置为透明
    systemNavigationBarColor: EMPColor.dark_bg_color,//系统导航栏的背景颜色
    systemNavigationBarIconBrightness: Brightness.light,//系统导航栏上的图标 (light 浅色)
    statusBarIconBrightness: Brightness.light,//设置状态栏上的图标
    statusBarBrightness: Brightness.dark,//状态栏的亮度
  );

  static const SystemUiOverlayStyle dark = SystemUiOverlayStyle(
    statusBarColor: Colors.transparent,
    systemNavigationBarColor: Colors.white,
    systemNavigationBarIconBrightness: Brightness.dark,
    statusBarIconBrightness: Brightness.dark,
    statusBarBrightness: Brightness.light,
  );

}

extension EMPThemeExt on BuildContext {
  bool get isDark => EMPTheme.isDark(this);
  Color get backgroundColor => Theme.of(this).scaffoldBackgroundColor;//当前主题的背景色
  Color get dialogBackgroundColor => Theme.of(this).canvasColor;//对话框背景色
}